package com.ds.api.utils.message;

import java.util.ArrayList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 发送短信api
 * @className: SendMessageUtil
 * @description: TODO
 * @author xiangwei
 */
public class SendMessageUtil {
    
    private final static String APPKEY="81ed3928fd29214e766bc5f3b6eb8d94";
    
    private final static int TEMPID=18723;
    
    private final static int APPID=1400027642;
    
    private static final Logger log = LoggerFactory
            .getLogger(SendMessageUtil.class);
    
    
    public static SmsSingleSenderResult sendMessage(String phoneNumber,String number){
        SmsSingleSenderResult singleSenderResult=null;
        try {
       
         //初始化单发
        SmsSingleSender singleSender = new SmsSingleSender(APPID, APPKEY);
        
         //普通单发
//        singleSenderResult = singleSender.send(0, "86", phoneNumber1, "您注册的验证码：1234", "", "");
//        System.out.println(singleSenderResult);

         //指定模板单发
         //假设短信模板 id 为 1，模板内容为：测试短信，{1}，{2}，{3}，上学。
        ArrayList<String> params = new ArrayList<String>();
        params.add(number);
        singleSenderResult = singleSender.sendWithParam("86", phoneNumber, TEMPID, params, "", "", "");
        }
        catch (Exception e) {
            log.error("发送短信失败", e);
        }
        return singleSenderResult;
    }
}
